#!/bin/bash

PROJECT_PATH="/Users/yzw/IdeaProjects/gyux"
REMOTE_NAME="github"
GITHUB_SSH_URL="git@github.com:18684917101/gyux.git"

cd "$PROJECT_PATH" || {
  echo "❌ 项目目录不存在：$PROJECT_PATH"
  exit 1
}

# 强制设置 GitHub 远程地址为 SSH
git remote set-url "$REMOTE_NAME" "$GITHUB_SSH_URL"

# 获取当前分支
BRANCH=$(git rev-parse --abbrev-ref HEAD)

echo "🚀 当前分支：$BRANCH"
echo "📤 正在通过 SSH 推送到 GitHub..."

git push "$REMOTE_NAME" "$BRANCH"

if [ $? -eq 0 ]; then
  echo "✅ 推送成功！"
else
  echo "❌ 推送失败，请先检查 ssh -T git@github.com 是否成功"
fi
